<template>
  <div class="search">
    <el-form @submit.left.prevent inline>
      <div>
        <slot name="headline"></slot>
      </div>
      <slot name="normal"></slot>
      <div v-if="block && showMore">
        <slot name="advantage"></slot>
      </div>
      <div>
        <slot name="button" v-if="!showMore"></slot>
        <slot name="button" v-if="showMore"></slot>
      </div>
      <div v-if="block">
        <el-form-item>
          <el-button
            v-if="!showMore"
            class="btn-more"
            link
            @click="showMore = true"
          >
            <span>展开</span>
            <el-icon><arrow-down-bold /></el-icon>
          </el-button>
          <el-button
            v-if="showMore"
            class="btn-more"
            type="text"
            @click="showMore = false"
          >
            <span>收起</span>
            <el-icon><arrow-up-bold /></el-icon>
          </el-button>
        </el-form-item>
      </div>
      <div class="toolbar">
        <slot name="toolbar"></slot>
      </div>
    </el-form>
  </div>
</template>
<script lang="ts">
export default {
  name: 'SearchBar'
}
</script>

<script lang="ts" setup>
const router = useRouter();
const func = defineProps({
  block: {
    type: Boolean,
    default: false,
  },
  defaultShowMore: {
    type: Boolean,
    default: false,
  },
});
const showMore = ref(false);
showMore.value = func.defaultShowMore;
</script>

<style lang="scss" scoped>
.search {
  position: relative;
  border: 0;
  background: #ffffff;
  //padding: 10px 20px;
  :deep(.el-form) {
    display: flex;
    align-items: center;
    height: auto;
    flex-wrap: wrap;
    //margin-top: 10px;
  }
  :deep(.el-input__inner) {
    width: 208px;
    overflow-x: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    &.el-range-editor{
      overflow-y: hidden;
      width: auto;
    }
  }
  :deep(.el-input__wrapper) {
    padding: 0 10px;
  }
  :deep(.el-button--primary) {
    color: #ffffff;
    .el-icon {
      color: #ffffff;
    }
  }
  .btn-more {
    display: flex;
    align-items: center;
    span {
      margin-right: 5px;
    }
  }
  .toolbar {
    display: flex;
    justify-content: flex-end;
  }
  :deep(.el-input--mini .el-input__icon) {
    line-height: 32px;
  }
  :deep(.el-range-editor--mini .el-range__icon) {
    line-height: 32px;
  }
}
</style>
